<?php
html::printPath(array(
		'seminar.form-title' => 'admin/seminar/all',
		$seminar['name'] => '/admin/seminar/display?id=' . $seminar['id'],
		'seminar.registrationOverview' => ''
	)
);
$msg->printMessages();
?>

<ul class="commandList">
    <li class="searchCommand"><?php echo html::searchEntityAnchor($this); ?></li>
</ul>

<?php
echo '<ul class="commandList">';
echo '<li class="exportToExcel">' . html::anchor('/admin/person/exportToExcel', text::get('application.exportToExcel')) . '</li>';
echo '</ul>';

$elb = new EntityListBuilder($this, $registrationList);
$elb->rowCssClassFunction('cancelledRowClass');
$elb->integer('id')->linkWithValue('/admin/registration/display?id=', 'id')->openInPopup();
$elb->text('person_id')->doubleValue('last_name', 'first_name')->alignLeft()->orderByField('last_name')->linkWithValue('/admin/person/display?id=', 'person_id');
$elb->text('idcard_number')->labelKey('person.idcard_number')->valueFunction('registrationHelper::idCardFunction', '/admin/registration/idCardForm');
$elb->text('is_present')->valueFunction('registrationHelper::presenceFunction', '/admin/registration/togglePresence');
$elb->text('key_deposit')->valueFunction('registrationHelper::keyDepositFunction', '/admin/registration/keyDepositForm');
$elb->text('is_key_returned')->valueFunction('registrationHelper::keyReturnedFunction', '/admin/registration/toggleKeyReturned');
$elb->timestamp('created_at');
$elb->text('payment_type')->l10n('registration.paymentType-');
$elb->price('total_price', 'currency_code')->alignRight();
$elb->timestamp('confirmed_at');
$elb->text('confirmed_by_last_name')->labelKey('registration.confirmed_by_id')->doubleValue('confirmed_by_first_name', 'confirmed_by_last_name');
$elb->longText('org_notes');
$elb->write();

function cancelledRowClass($registration) {
	if ($registration['cancelled_at']) {
		return 'cancelledRegRow';
	}
	return '';
}

function presenceFunction($registration, $entityListField) {
	$html = html::anchor('#',
			format::twoValueBoolean($registration['is_present']),
			array(
				'title' => text::get('registration.togglePresence'),
				'onclick' => "Yosemin.Ajax.partialPageUpdate('" . url::site('/reception/recRegistration/togglePresence') . "', null, {id:" . $registration['id'] . "}, null); return false;",
				'id' => 'presence_' . $registration['id']
			)
	);
	if (! $registration['confirmed_at']) {
		$html = '! ' . $html . ' !';
	}
	return $html;
}
